From: Jo-Philipp Wich Date: Fri, 9 Sep 2022 18:08:57 +0000 (+0200) Subject: luci-theme-bootstrap: translate Lua templates to ucode equivalents X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=2e3282e624836c9e7cd425dee6eec708038b3a26;p=project%2Fluci.git luci-theme-bootstrap: translate Lua templates to ucode equivalents Add ucode template equivalents for the Lua templates used by the theme. Signed-off-by: Jo-Philipp Wich --- diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark deleted file mode 120000 index ac7bcbbf37..0000000000 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark +++ /dev/null @@ -1 +0,0 @@ -bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light deleted file mode 120000 index ac7bcbbf37..0000000000 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light +++ /dev/null @@ -1 +0,0 @@ -bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm deleted file mode 100644 index 48d9b98b92..0000000000 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm +++ /dev/null @@ -1,21 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Copyright 2012 David Menting - Licensed to the public under the Apache License 2.0. --%> - - <% if not blank_page then %> - <% local ver = require "luci.version" %> - - - - <% end %> - - - diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm deleted file mode 100644 index 37d18a2f07..0000000000 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm +++ /dev/null @@ -1,95 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2016 Jo-Philipp Wich - Copyright 2012 David Menting - Licensed to the public under the Apache License 2.0. --%> - -<% - local sys = require "luci.sys" - local util = require "luci.util" - local http = require "luci.http" - local disp = require "luci.dispatcher" - - local boardinfo = util.ubus("system", "board") - - local node = disp.context.dispatched - - local darkpref - - if theme == "bootstrap-dark" then - darkpref = "true" - elseif theme == "bootstrap-light" then - darkpref = "false" - end - - -- send as HTML5 - http.prepare_content("text/html") --%> - -> - - - <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI - <% if darkpref == nil then %> - - <% end %> - - - - - <% if node and node.css then %> - - <% end -%> - <% if css then %> - - <% end -%> - - - - - "> - <% if not blank_page then %> -
- <%=striptags(boardinfo.hostname or "?")%> - -
-
- -
- <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%> -
-

<%:No password set!%>

-

<%:There is no password set on this router. Please configure a root password to protect the web interface.%>

- <% if disp.lookup("admin/system/admin") then %> - - <% end %> -
- <%- end -%> - - <%- if boardinfo.rootfs_type == "initramfs" then -%> -
-

<%:System running in recovery (initramfs) mode.%>

-

<%:No changes to settings will be stored and are lost after rebooting. This mode should only be used to install a firmware upgrade%>

- <% if disp.lookup("admin/system/flash") then %> - - <% end %> -
- <%- end -%> - - - - - <% end %> diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/sysauth.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/sysauth.htm deleted file mode 100644 index 72b04783bb..0000000000 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/sysauth.htm +++ /dev/null @@ -1,53 +0,0 @@ -<%# - Copyright 2021 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - -- tell bootstrap's templates to not render header and footer - blank_page = true -%> - -<%+header%> - - - -
-
<%:Loading view…%>
- -
- -<%+footer%> diff --git a/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-dark b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-dark new file mode 120000 index 0000000000..ac7bcbbf37 --- /dev/null +++ b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-dark @@ -0,0 +1 @@ +bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-light b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-light new file mode 120000 index 0000000000..ac7bcbbf37 --- /dev/null +++ b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap-light @@ -0,0 +1 @@ +bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/footer.ut b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/footer.ut new file mode 100644 index 0000000000..6031724053 --- /dev/null +++ b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/footer.ut @@ -0,0 +1,20 @@ + {% if (!blank_page): %} +
+ + + {% endif %} + + diff --git a/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/header.ut b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/header.ut new file mode 100644 index 0000000000..b7bc770b4b --- /dev/null +++ b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/header.ut @@ -0,0 +1,83 @@ +{# + Copyright 2008 Steven Barth + Copyright 2012 David Menting + Copyright 2008-2022 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-#} + +{% + import { getuid, getspnam } from 'luci.core'; + + const boardinfo = ubus.call('system', 'board'); + const darkpref = (theme == 'bootstrap-dark' ? 'true' : (theme == 'bootstrap-light' ? 'false' : null)); + + http.prepare_content('text/html; charset=UTF-8'); +-%} + + + + + + {{ striptags(`${boardinfo.hostname ?? '?'}${node ? ` - ${node.title}` : ''}`) }} - LuCI + {% if (!darkpref): %} + + {% endif %} + + + + + {% if (node?.css): %} + + {% endif %} + {% if (css): %} + + {% endif %} + + + + + + {% if (!blank_page): %} +
+ {{ striptags(boardinfo.hostname ?? '?') }} + +
+
+ +
+ {% if (getuid() == 0 && getspnam('root')?.pwdp === ''): %} +
+

{{ _('No password set!') }}

+

{{ _('There is no password set on this router. Please configure a root password to protect the web interface.') }}

+ {% if (dispatcher.lookup("admin/system/admin")): %} + + {% endif %} +
+ {% endif %} + + {% if (boardinfo.rootfs_type == "initramfs"): %} +
+

{{ _('System running in recovery (initramfs) mode.') }}

+

{{ _('No changes to settings will be stored and are lost after rebooting. This mode should only be used to install a firmware upgrade') }}

+ {% if (dispatcher.lookup("admin/system/flash")): %} + + {% endif %} +
+ {% endif %} + + + + + {% endif %} diff --git a/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/sysauth.ut b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/sysauth.ut new file mode 100644 index 0000000000..a172d95d76 --- /dev/null +++ b/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/sysauth.ut @@ -0,0 +1,48 @@ +{# + Copyright 2022 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-#} + +{% include('header', { blank_page: true }) %} + + + +
+
{{ _('Loading view…') }}
+ +
+ +{% include('footer', { blank_page: true }) %}